package com.popay.es.utils;


import java.util.*;

/**
 * @version v1.0
 * @ProjectName: popay-parent
 * @ClassName: DoubleColorBall
 * @Description: TODO(一句话描述该类的功能)
 * @Author: 晨曦
 * @Date: 2021/6/27 14:31
 */
public class DoubleColorBall {
    public static void main(String[] args) {

        int sizeRed = 31;
        int sizeBlue = 16;
        List<Integer> redBallList = new ArrayList<>();
        List<Integer> blueBallList = new ArrayList<>();
        for(int redsize= 1 ;redsize<=6;redsize++  ){
            redBallList.add(getRedBall(sizeRed,redBallList));
        }

        blueBallList.add(getBlueBall(sizeBlue,blueBallList));
        Collections.sort(redBallList);
        System.out.println(redBallList);
        Collections.sort(blueBallList);
        System.out.println(blueBallList);

    }

    public static int getRedBall(int sizeRed, List<Integer> redBallList) {
        Random redBallRandom = new Random();
        int redBall = redBallRandom.nextInt(sizeRed);
        if(redBallList !=null && !redBallList.isEmpty()){
            while (redBallList.contains(redBall) || redBall == 0) {
                getRedBall(sizeRed, redBallList);
            }
        }
        return redBall;
    }

    public static int getBlueBall(int sizeBlue, List<Integer> blueBallList) {
        Random blueBallRandom = new Random();
        int blueBall = blueBallRandom.nextInt(sizeBlue);
        if(blueBallList !=null && blueBallList.isEmpty()){
            while (blueBallList.contains(blueBall)|| blueBall == 0) {
                getBlueBall(sizeBlue, blueBallList);
            }
        }
        return blueBall;
    }
}
